package com.shuzixiangcun.service.admin;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.shuzixiangcun.entity.JobPostings;
import com.shuzixiangcun.entity.Members;
import com.shuzixiangcun.dao.MembersDao;
import org.springframework.stereotype.Service;


import javax.annotation.Resource;
import java.util.List;

/**
 * 成员信息表(Members)表服务实现类
 *
 * @author makejava
 * @since 2024-07-02 17:39:43
 */
@Service
public class MembersServiceImpl{
    @Resource
    private MembersDao membersDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */

    public Members queryById(Integer id) {
        return this.membersDao.queryById(id);
    }



    /**
     * 新增数据
     *
     * @param members 实例对象
     * @return 实例对象
     */

    public Members insert(Members members) {
        this.membersDao.insert(members);
        return members;
    }

    /**
     * 修改数据
     *
     * @param members 实例对象
     * @return 实例对象
     */

    public Members update(Members members) {
        this.membersDao.update(members);
        return this.queryById(members.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */

    public boolean deleteById(Integer id) {
        return this.membersDao.deleteById(id) > 0;
    }


    public List<Members> getMembers(Integer id,Integer user_id) {
        return this.membersDao.queryListByUserId(id,user_id);
    }

    public PageInfo<Members> getPageInfo(Integer pageNo, Integer pageSize) {
        PageHelper.startPage(pageNo, pageSize,true);
        List<Members> mangerList=membersDao.getMembersList();
        return new PageInfo<Members>(mangerList);
    }

    public int updateByState(Members members) {

        return this.membersDao.updateByState(members);
    }
}
